/********************************************************************
	Rhapsody	: 7.5 
	Login		: KBE
	Component	: DefaultComponent 
	Configuration 	: CodeConfig
	Model Element	: Log
//!	Generated Date	: Wed, 26, Sep 2012  
	File Path	: DefaultComponent\CodeConfig\Log.cpp
*********************************************************************/

//## auto_generated
#include "Log.h"
//## auto_generated
#include "LF_EventHandler.h"
//## auto_generated
#include "Reactor.h"
//## package Default

//## class Log
Log::Log() {
}

Log::~Log() {
}

void Log::handleEvent(HANDLE h, Event_Type& et) {
    //#[ operation handleEvent(HANDLE,Event_Type)
    if (et == type) {
    	int n = getPeer_stream_()->recv_n(buffer_, sizeof(buffer_), 0);
    	if (n > 0) { 
    		LogAction();
    	}
    	else 
    	{
    		//itsReactor->removeHandler(*this, type);
    		//delete this; // Deallocate ourselves
    	}
    }
    //#]
}

char Log::getBuffer_(int i1) const {
    return buffer_[i1];
}

void Log::setBuffer_(int i1, char p_buffer_) {
    buffer_[i1] = p_buffer_;
}

Log::Log(Reactor* reactor) {
    //#[ operation Log(Reactor*)
     itsReactor = reactor;
    //#]
}

void Log::LogAction() {
    //#[ operation LogAction()
    printf("Log: %s\n", buffer_);
    //#]
}

void Log::saveLog(char* log) {
    //#[ operation saveLog(char*)
    if (strlen(log) < sizeof(buffer_))
    {
    	strcpy(buffer_, log);
    	getPeer_stream_()->send_n(buffer_, sizeof(buffer_), 0);
    }
    //#]
}

/*********************************************************************
	File Path	: DefaultComponent\CodeConfig\Log.cpp
*********************************************************************/
